- unmark_label = :unmark.ta
- unmark_title = :unmark.tl
- confirm_label = :are_you_sure.tl
- account_id = @account.id

= kujaku do |k|
  - k.helper(:journal_period_crit, use_search_preference: true)
= form_tag() do

  = field_set :details do
    = attributes_list(@account, stamps: false) do |l|
      - l.attribute :name, url: true
      - l.attribute :number, url: true
      - l.attribute :description

    = error_messages "account"

  = field_set :items do
    - currency = Preference[:currency]
    - precision = Nomen::Currency[currency].precision
    - [:period, :started_at, :stopped_at].each do |x|
      = hidden_field_tag(x, params[x])

    %span.action-form.btn-group.hidden
      = link_to :add_compensation_entry.tl, { controller: :journal_entries, action: :new, redirect: request.fullpath }, { class: 'btn btn-default', id: 'new-entry', name: :journal_entry_items_ids, data: { complete_link_with_checked_row_ids: '#mark_journal_entry_items input[type="checkbox"]', show_if_checked: 'two-or-more' } }

    .active-list-actions
      - lettered_items_preference = current_user.preference('backend/accounts.mark_journal_entry_items.lettered_items.masked', 'true', :boolean)
      = refresh_lettered_items_button :mark_journal_entry_items, default_value: lettered_items_preference.value, period: params[:period], started_on: params[:started_on].to_s, stopped_on: params[:stopped_on].to_s, account_id: account_id

    - items = @account.reconcilable_entry_items(params[:period], params[:started_on], params[:stopped_on], hide_lettered: lettered_items_preference.value)
    - partial_lettering = items.any?(&:partially_lettered?)
    .active-list#mark_journal_entry_items
      %table.list
        %thead
          %tr
            %th{ colspan: (partial_lettering ? 2 : 1) }= JournalEntryItem.human_attribute_name(:letter)
            %th.act
            %th= JournalEntry.human_attribute_name(:printed_on)
            %th= JournalEntry.model_name.human
            %th= JournalEntryItem.human_attribute_name(:name)
            %th= JournalEntryItem.human_attribute_name(:absolute_debit)
            %th= JournalEntryItem.human_attribute_name(:absolute_credit)

        %tfoot
          %tr#total.valid.total{data: {valid_if_equality_between: "#total-debit, #total-credit", submit_if_valid: "true"}}
            %th{colspan: 5 + (partial_lettering ? 1 : 0)}= :total.tl
            %td#total-debit{data:  {use: "tr.selected .debit", calculate_round: precision}}=  0
            %td#total-credit{data: {use: "tr.selected .credit", calculate_round: precision}}= 0

        %tbody
          = render partial: 'mark_items', locals: { items: items, unmark_title: unmark_title, confirm_label: confirm_label, unmark_label: unmark_label, account_id: account_id, currency: currency }
